class UIHUD extends UTHUD;

var UIPlayerController PC;

function DrawBar(String Title, float Value, float MaxValue,int X, int Y, int R, int G, int B)
{

    local int PosX,NbCases,i;

    PosX = X; // Where we should draw the next rectangle
    NbCases = 10 * Value / MaxValue; // Number of active rectangles to draw
    i=0; // Number of rectangles already drawn

    /* Displays active rectangles */
    while(i < NbCases && i < 10)
    {
        Canvas.SetPos(PosX,Y);
        Canvas.SetDrawColor(R,G,B,200);
        Canvas.DrawRect(12,20);

        PosX += 15;
        i++;

    }

    /* Displays desactived rectangles */
    while(i < 10)
    {
        Canvas.SetPos(PosX,Y);
        Canvas.SetDrawColor(255,255,255,80);
        Canvas.DrawRect(12,20);

        PosX += 15;
        i++;

    }

    /* Displays a title */
    Canvas.SetPos(X,Y-20);//(PosX + 5,Y);
    Canvas.SetDrawColor(R,G,B,200);
    Canvas.Font = class'Engine'.static.GetMediumFont();
    Canvas.DrawText(Title);

} 

function DrawScore(String Title, int Score, int X, int Y, int R, int G, int B)
{
	local float sizX, sizY;
    Canvas.SetDrawColor(R,G,B,200);
    Canvas.Font = class'Engine'.static.GetLargeFont();
	Canvas.TextSize(Title$Score, sizX, sizY);
    Canvas.SetPos(X - sizX,Y);
    Canvas.DrawText(Title$Score);
} 

function DrawWave(String Title, int Wave, int X, int Y, int R, int G, int B)
{
	local float sizX, sizY;
    Canvas.SetDrawColor(R,G,B,200);
    Canvas.Font = class'Engine'.static.GetLargeFont();
	Canvas.TextSize(Title$Wave, sizX, sizY);
    Canvas.SetPos(X/sizX,Y);
    Canvas.DrawText(Title$Wave);
}

function DrawLives(String Title, int Lives, int X, int Y, int R, int G, int B)
{
    local float sizX, sizY;
    Canvas.SetDrawColor(R,G,B,200);
    Canvas.Font = class'Engine'.static.GetLargeFont();
    Canvas.TextSize(Title$Lives, sizX, sizY);
    Canvas.SetPos(X - sizX,Y);
    Canvas.DrawText(Title$Lives);
}

event PostRender()
{
	Super.PostRender();

	if (PlayerOwner != None && PlayerOwner.PlayerInput != None)
	{

		// Type cast the PlayerOwner property of the HUD to UIPlayerController
		PC = UIPlayerController(PlayerOwner);
		
		//TODO: change this to a proper hud
        DrawLives("Lives: ", PlayerOwner.Pawn.Health/100,  Canvas.SizeX - 10, 30, 255, 100, 80);
		DrawBar("Health",PlayerOwner.Pawn.Health/100.0 * 100.0, 100,20,30,255,80,80); 
		DrawScore("Score: ", PC.UIPoints, Canvas.SizeX - 10, 10, 255, 100, 80);
		//Canvas.DrawText("aTilt in degrees = (Pitch = "$PlayerOwner.PlayerInput.aTilt.X * UnrRotToDeg$",Yaw = "$PlayerOwner.PlayerInput.aTilt.Y * UnrRotToDeg$",Roll = "$PlayerOwner.PlayerInput.aTilt.Z * UnrRotToDeg$")");
	}
}

defaultproperties
{

}